import axios from 'axios'
import { message } from 'antd'

const apiurl = 'http://47.92.104.254:8087/qcenter'
// const apiurl = ''
message.config({
  duration: 1,
  maxCount: 1
})
axios.defaults.baseURL = apiurl
axios.interceptors
  .response
  .use((response) => {
    return response.data
  }, (error) => {
    if (error.response && error.response.status === 400) {
      message.error(error.response.data.message)
    }else {
      error.response && message.error(error.response.data.message)
    }
    return Promise.reject(error)
  })

export default {
  request(options){
    return axios(options)
  },
  apiurl
}
